﻿#ifndef _TABLE_DECLARE_
#define _TABLE_DECLARE_

/*
    增益控制字表格
*/
//增益对应引脚控制字，0-63，对应P1OUT(76XX3210)
extern const unsigned char mask[64] = {
    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
    0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
    0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
    0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
    0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
    0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
    0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF
};

/*
    声明波形发生相关表格
*/
//方波
extern const unsigned char squarewave[] = {
    60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
    60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
    60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
//三角波
extern const unsigned char triangwave[] = {
    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 
    20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 
    40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 
    39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 
    19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
};
//锯齿波
extern const unsigned char sawtoowave[] = {
    0, 0, 1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 10, 10, 11, 12, 
    12, 13, 14, 14, 15, 15, 16, 17, 17, 18, 19, 19, 20, 21, 21, 22, 22, 23, 24, 24, 
    25, 26, 26, 27, 28, 28, 29, 29, 30, 31, 31, 32, 33, 33, 34, 35, 35, 36, 36, 37, 
    38, 38, 39, 40, 40, 41, 42, 42, 43, 43, 44, 45, 45, 46, 47, 47, 48, 49, 49, 50, 
    50, 51, 52, 52, 53, 54, 54, 55, 56, 56, 57, 57, 58, 59, 59, 60, 61, 61, 62, 63
};
//正弦波
extern const unsigned char sincoswave[] = {
    0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 19, 21, 23, 25, 27, 29, 30, 32, 34, 35, 
    37, 39, 40, 42, 43, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 59, 
    60, 60, 61, 61, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 61, 61, 60, 60, 
    59, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 47, 46, 45, 43, 42, 40, 39, 37, 
    35, 34, 32, 30, 29, 27, 25, 23, 21, 19, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0
};

/*
    声明音乐播放相关表格
*/

//音调频率对照表
//C大调
extern const unsigned int tone1[][5]=
{
    {131,262,523,1046,2093}, //DO
    {147,294,587,1175,2349}, //RE
    {165,330,659,1318,2637}, //MI
    {175,349,698,1397,2794}, //FA
    {196,392,784,1568,3136}, //SO
    {220,440,880,1760,3520}, //LA
    {247,494,988,1967,3951}  //XI
};

//12平均律
extern const unsigned int tone2[][5]=
{
    {131,262,523,1046,2093}, //DO
    {139,277,554,1109,2217}, //#DO
    {147,294,587,1175,2349}, //RE
    {155,311,622,1244,2489}, //#RE
    {165,330,659,1318,2637}, //MI
    {175,349,698,1397,2794}, //FA
    {185,370,740,1480,2960}, //#FA
    {196,392,784,1568,3136}, //SO
    {208,415,831,1661,3322}, //#SO
    {220,440,880,1760,3520}, //LA
    {233,466,932,1865,3729}, //#LA
    {247,494,988,1967,3951}, //XI
};

//荷塘月色-C大调版
extern const unsigned int music_data0[][2]=
{
    {21,600},{25,200},{21,200},{25,200},{21,200},{22,200},{23,1600},
    {21,600},{25,200},{21,200},{25,200},{21,200},{22,200},{22,1600},
    {21,600},{25,200},{21,200},{25,200},{22,200},{21,200},{16,1000},{15,200},{21,200},{22,200},
    {21,600},{25,200},{21,200},{25,200},{21,200},{16,200},{21,1600},
    {21,200},{21,400},{16,200},{15,400},{16,400},
    {21,400},{21,200},{22,200},{23,800},
    {22,200},{22,400},{21,200},{22,400},{22,200},{25,200},
    {25,200},{23,200},{23,200},{22,200},{23,800},
    {21,200},{21,400},{16,200},{15,400},{25,400},
    {23,200},{22,200},{23,200},{22,200},{21,800},
    {22,200},{22,400},{21,200},{22,200},{22,400},{23,200},
    {22,200},{21,200},{16,200},{22,200},{21,800},
    {21,200},{21,400},{16,200},{15,400},{16,400},
    {21,200},{21,400},{22,200},{23,800},
    {22,200},{22,400},{21,200},{22,400},{22,200},{25,200},
    {25,200},{23,200},{23,200},{22,200},{23,800},
    {21,200},{21,200},{21,200},{16,200},{15,400},{25,400},
    {23,200},{22,200},{23,200},{22,200},{21,800},
    {22,200},{22,400},{21,200},{22,200},{22,400},{23,200},
    {22,200},{21,200},{16,200},{22,200},{21,800},
    {23,200},{25,400},{25,200},{25,400},{25,400},
    {26,200},{25,200},{23,200},{22,200},{21,800},
    {26,200},{31,200},{26,200},{25,200},{23,200},{22,200},{21,200},{16,200},
    {22,400},{22,200},{23,200},{23,200},{22,600},
    {23,200},{25,400},{25,200},{25,400},{25,400},
    {26,200},{25,200},{23,200},{22,200},{21,800},
    {16,200},{21,200},{16,200},{15,200},{22,400},{23,400},
    {21,1200},{0,400},
    {0,0}
};

//自新大陆-C大调版
extern const unsigned int music_data1[][2]=
{
    {23,600},{25,200},{25,800},{23,600},{22,200},{21,800},{22,600},{23,200},{25,600},{23,200},{22,1600},
    {23,600},{25,200},{25,800},{23,600},{22,200},{21,800},{22,400},{23,400},{22,600},{21,200},{21,1600},
    {26,600},{31,200},{31,800},{27,200},{25,200},{26,800},{26,600},{31,200},{27,400},{25,400},{26,1600},
    {26,600},{31,200},{31,800},{27,200},{25,200},{26,800},{26,600},{31,200},{27,400},{25,400},{26,1600},
    {23,600},{25,200},{25,800},{23,600},{22,200},{21,800},{22,600},{23,200},{25,600},{23,200},{22,1600},
    {23,600},{25,200},{25,800},{31,600},{32,200},{33,800},{32,600},{31,200},{32,400},{26,400},{31,1600},
    {0,0}
};


//告白气球-C大调版
extern const unsigned int music_data2[][2]=
{
    {25,200},{31,200},{27,200},{21,200},{0,400},{25,200},{22,400},{23,200},{23,600},
    {0,200},{25,200},{31,200},{27,200},{25,200},{21,200},
    {0,200},{25,200},{22,400},{23,200},{24,200},{23,400},{0,200},
    {25,200},{32,200},{31,200},{27,200},{31,400},
    {32,200},{33,400},{31,400},{26,600},{27,200},{31,400},
    {25,600},{25,200},{24,200},{23,200},{22,600},{21,400},{21,600},{22,1000},
    {21,100},{21,100},{17,100},{21,200},{17,200},{21,100},{17,100},{0,200},
    {22,300},
    {17,100},{17,200},{16,100},{17,200},{16,200},{17,100},{16,100},{0,200},{21,600},
    {16,200},{21,200},{23,200},{22,200},{21,200},{23,1000},{0,200},
    {21,100},{21,100},{17,100},{21,200},{17,200},{21,100},{17,100},{0,200},
    {22,300},
    {17,100},{17,200},{16,100},{17,200},{16,200},{17,100},{16,100},{0,200},{21,600},
    {16,200},{21,200},{23,200},{22,200},{21,200},{21,1000},
    {16,200},{17,200},{21,200},{21,200},{21,200},{21,200},{16,400},
    {16,200},{17,200},{21,200},{21,200},{21,200},{22,200},{22,400},
    {15,200},{16,200},{17,200},{17,200},{17,200},{17,200},{15,400},
    {15,200},{16,200},{17,200},{17,200},{17,200},{21,200},{21,400},
    {21,200},{22,200},{23,200},{23,200},{23,200},{16,200},{21,400},
    {21,200},{22,200},{23,200},{23,200},{23,200},{16,200},{21,400},
    {21,200},{22,200},{23,200},{23,200},{23,200},{23,400},{21,200},{22,200},{22,1000},
    {0,200},{15,200},{24,200},{23,600},{24,200},{23,400},{22,600},
    {21,400},{22,200},{23,400},{21,600},
    {16,400},{21,200},{25,400},{21,200},{25,400},{23,200},{23,1000},
    {0,200},{15,200},{24,200},{23,600},{24,200},{23,400},{22,600},
    {21,400},{22,200},{23,400},{26,600},
    {25,400},{17,200},{21,400},{22,400},{21,1000},
    {0,0}   
};

//only my railgun-12平均律版
extern const unsigned int music_data3[][2]=
{
//    {109,150},{109,150},{107,75},{109,75},{0,150},{109,150},{109,150},{107,75},{109,75},
//    {0,150},{109,150},{109,150},{107,75},{109,75},{0,150},{109,150},{109,150},{107,75},{109,75},
//    {0,150},{109,150},{109,150},{107,75},{109,75},{0,150},{109,150},{109,150},{107,75},{109,75},
//    {0,150},{109,150},{109,150},{107,75},{109,75},{0,150},{109,150},{109,150},{107,75},{109,75},
//    {0,150},{109,150},{109,150},{107,75},{109,75},{0,150},{109,150},{109,150},{107,75},{109,75},
//    {0,150},{109,150},{109,150},{107,75},{109,75},{0,150},{109,150},{109,150},{107,75},{109,75},
//    {0,150},{109,150},{109,150},{107,75},{109,75},{0,150},{109,150},{109,150},{107,75},{109,75},
//    {0,150},{109,150},{109,150},{107,75},{109,75}, //前奏
    //B
    {0,150},{112,150},{110,150},{107,150},{107,150},{109,75},{109,225},
    {107,150},{107,150},{109,75},{109,225},{107,150},{107,150},{109,75},{109,225},
    {109,150},{109,150},{110,150},{112,150},{202,150},{110,300},{107,300},{205,300},{202,300},
    {202,225},{202,225},{203,150},
    {0,150},{112,150},{110,150},{107,150},{107,150},{109,75},{109,225},
    {107,150},{107,150},{109,75},{109,225},{107,150},{107,150},{109,75},{109,225},
    {109,150},{109,150},{110,150},{112,150},{202,150},{109,600},
    {109,150},{110,150},{112,150},{202,150},{110,300},{107,300},{103,300},{107,300},
    {107,150},{109,75},{109,225},{112,150},{110,150},{107,75},{103,75},
    {103,150},{107,150},{107,150},{109,75},{109,975},
    //降A
    {209,600},{209,150},{208,150},{209,150},{210,150},{209,600},{209,150},{208,150},{209,150},{210,150},
    {301,600},{301,150},{302,150},{201,150},{211,150},
    {301,150},{211,150},{208,150},{304,150},{301,600},
    {209,600},{209,150},{208,150},{209,150},{210,150},{209,600},{209,150},{208,150},{209,150},{210,150},
    {301,300},{205,300},{211,150},{209,150},{208,150},{209,150},
    {209,450},{206,150},{206,600},
    {301,150},{301,75},{301,150},{301,150},{301,75},{301,300},{301,150},{211,150},{209,150},
    {208,300},{208,300},{208,150},{208,150},{304,75},{304,525},
    {304,75},{304,75},{304,150},{302,150},{301,150},{211,150},
    {302,75},{301,150},{211,225},{209,150},{208,225},{208,225},{208,225},
    {206,150},{209,600},{209,150},{208,225},{208,225},{206,150},{209,600},
    {209,150},{209,75},{209,150},{209,75},{209,300},{209,150},{211,150},
    {212,150},{212,300},{212,150},{207,75},{207,375},{0,150},
    {207,150},{206,300},{206,150},{204,150},{206,150},{208,75},
    {209,225},{209,150},{209,450},{208,75},{206,75},{206,75},{208,600},
    {304,150},{0,75},{305,150},{0,75},{304,150},{0,150},{212,150},{211,150},{211,150},{207,150},
    {0,0}
//    B
};

#endif
